Skip to content

Emit FS0755 for CompiledName on multi-value let-bindings#19924

Open
T-Gro wants to merge 5 commits into
mainfrom
fix/issue-6131
Open

Emit FS0755 for CompiledName on multi-value let-bindings#19924
T-Gro wants to merge 5 commits into
mainfrom
fix/issue-6131

Conversation

@T-Gro

@T-Gro T-Gro commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fixes #6131

[<CompiledName("X")>]
let a, b = 1, 2
// before: silently duplicated the compiled name onto every val, crashing later with FS0192/FS2014
// after:  FS0755 at type-check time

Copilot and others added 4 commits June 9, 2026 16:08
…#6131)

Tests assert FS0755 is emitted at type-check time when [<CompiledName>]

is applied to a tuple/record/wildcard destructuring binding. These FAIL

on current main; sprint 02 will make them GREEN.

Baseline on main: 6 failed (the FS0755 tests), 4 succeeded (the still-compiles tests).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6131)

[<CompiledName(`X`)>] let a, b = 1, 2 silently propagated the same compiled name to every value introduced by the destructuring pattern, crashing later with FS0192 / FS2014 (duplicate IL entries) during IL writing. Detect destructuring patterns in TcNormalizedBinding (tuple/record/list/cons/or/ands/wild etc) and emit the existing FS0755 (tcCompiledNameAttributeMisused) diagnostic once, at the binding pattern range, during type checking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bindings (#6131)

Adds 11.0.100 release-note entry. Pure docs/formatting follow-up to the type-checker fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6131)

Replace the ~30-line syntactic SynPat walker (isSimpleValBindingPat) in TcNormalizedBinding with a single Map.count valSchemes > 1 check inside MakeAndPublishVals. The post-generalization val schemes are the authoritative count of values published by the binding, so the check is exact instead of approximate.

This removes false positives the walker produced (single-field record destructure, single-element array, single-binding cons, let a, _ = ...) and closes a false negative on let (x as y) = 1, which previously slipped through the walker and ICE'd in IlxGen.MergeOptions during IL writing.

Negative tests added for single-value destructures and active-pattern function bindings; the let (x as y) = 1 regression is added to the positive set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No current pull request URL (#19924) found, please consider adding it

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Jun 9, 2026
All 12 failing jobs on AzDO build 1456244 reported 'Unable to obtain an authenticated token for running job ... dnceng-public'. The 18 sibling jobs (Linux, MacOS, several Windows configs, CheckCodeFormatting) passed against the same commit, confirming the failures are infrastructure-only. Empty commit to force a new CI run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro requested a review from abonie June 12, 2026 10:08

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Looks good. The check placement in MakeAndPublishVals is the right spot — it's after generalization so Map.count valSchemes is authoritative for how many vals the binding actually publishes. Reusing FS0755 (tcCompiledNameAttributeMisused) is appropriate since the existing message text already covers this scenario.

Tests are thorough: covers tuples, nested tuples, record patterns, DU patterns, array/cons patterns, as patterns, verifies the error fires exactly once, and includes negative tests for single-val destructures and multi-case active patterns.

Minor nit (non-blocking): the range0 sentinel in the fold is a known idiom in the codebase but a one-liner match ... with [] -> range0 | ... might be marginally clearer. Not worth a revision.

CI green (50/50). LGTM.

@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

No service error for using CompiledName on multiple values

1 participant